<?php
use oxide\plugin\PluginAbstract;
use oxide\http\Context;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 * 
 * /Users/alaminahmed/SkyDrive/HD/workstation/web/aahmed.com/public/plugin/tinymce/tinymce/jquery.tinymce.js
 */

class TinyMCEPlugin extends PluginAbstract
{
   protected $_rootpath = null;
	
	public function onInit(Context $context) 
	{      
      $config = $this->getConfig();
      $rootpath = $config->getValue('root_path');
      $this->_rootpath = $rootpath;
		$this->register('ContentDefaultPostStart');
      $this->register('AdminContentPostForm');
	}
	
	public function onContentDefaultPostStart($event, $sender, $args = null)
	{
		oxide\util\Loader::loadHelper('_html');
		
		_html::script($this->_rootpath . '/tinymce/jquery.tinymce.js');
      _html::script($this->_rootpath . '/tinymce/tiny_mce.js');
		_html::script($this->_rootpath . '/load.js');
	}
   
   public function onAdminContentPostForm($event, $sender, $args)
   {
      $form = $args['form'];
      $control = $form->getControl('content');
      if(!$control->getValue()) $control->setValue('n/a');
   }
}

?>
